package top.yudoge.dogeeditor.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yudoge.dogeeditor.domain.DeKnowledge;
import top.yudoge.dogeeditor.mapper.DeKnowledgeMapper;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeKnowledgeService {

    @Autowired
    private DeKnowledgeMapper deKnowledgeMapper;

    public void save(String chatHistory) {
        DeKnowledge deKnowledge = new DeKnowledge();
        deKnowledge.setOriginalChatHistory(chatHistory);
        deKnowledge.setCreateTime(LocalDateTime.now());
        deKnowledgeMapper.insert(deKnowledge);
    }

    public List<DeKnowledge> listAll() {
        return deKnowledgeMapper.selectAll();
    }

    public void delete(Long id) {
        deKnowledgeMapper.delete(id);
    }
}
